/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package sistemareunioes;

import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import modelo.ModeloReuniao;
import modelo.ModeloUsuario;
import static sistemareunioes.TelaCadastroUsuario.conecta;
import utilitarios.ControleReunioes;
import utilitarios.ControleUsuarios;
import utilitarios.conectaBanco;
import utilitarios.UtilitariosTables;

/**
 *
 * @author Julia
 */
public class CadastroReuniao extends javax.swing.JFrame {
    ModeloUsuario gerente = new ModeloUsuario();

    /**
     * Creates new form ContactEditorUI
     */
    public CadastroReuniao(ModeloUsuario gerente) {
        initComponents();
        this.gerente = gerente;
    }
    
    public CadastroReuniao() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollBar1 = new javax.swing.JScrollBar();
        jScrollPane2 = new javax.swing.JScrollPane();
        painelPrincipal = new javax.swing.JPanel();
        lbNome = new javax.swing.JLabel();
        jCadastroCompromissoNome = new javax.swing.JTextField();
        HInicio = new javax.swing.JLabel();
        jCadastroCompromissoHoraInicio = new javax.swing.JFormattedTextField();
        HTermino = new javax.swing.JLabel();
        jCadastroHoraFim = new javax.swing.JFormattedTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jCadastroCompromissoDescricao = new javax.swing.JTextArea();
        descricao = new javax.swing.JLabel();
        btnSalvar = new javax.swing.JToggleButton();
        btnCancelar = new javax.swing.JToggleButton();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jCadastroCompromissoData = new javax.swing.JFormattedTextField();
        jLabel1 = new javax.swing.JLabel();
        jButtonDisponibilidade = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTabelaCandidatos = new javax.swing.JTable();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextAreaUsuarioEscolhidos = new javax.swing.JTextArea();
        BarradeMenus = new javax.swing.JMenuBar();
        menuArquivo = new javax.swing.JMenu();
        subMenuSair = new javax.swing.JMenuItem();
        menuSobre = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Principal");
        setResizable(false);

        painelPrincipal.setBorder(javax.swing.BorderFactory.createTitledBorder("Nova Reunião"));

        lbNome.setText("Nome da Reunião:");

        jCadastroCompromissoNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCadastroCompromissoNomeActionPerformed(evt);
            }
        });

        HInicio.setText("Hora de inicio");

        try {
            jCadastroCompromissoHoraInicio.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##:##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jCadastroCompromissoHoraInicio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCadastroCompromissoHoraInicioActionPerformed(evt);
            }
        });

        HTermino.setText("Hora de término");

        try {
            jCadastroHoraFim.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##:##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jCadastroHoraFim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCadastroHoraFimActionPerformed(evt);
            }
        });

        jCadastroCompromissoDescricao.setColumns(20);
        jCadastroCompromissoDescricao.setRows(5);
        jScrollPane1.setViewportView(jCadastroCompromissoDescricao);

        descricao.setText("Descrição ");

        btnSalvar.setText("Salvar");
        btnSalvar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnSalvarMouseClicked(evt);
            }
        });
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });

        btnCancelar.setText("Cancelar");
        btnCancelar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnCancelarMouseClicked(evt);
            }
        });
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/door_out.png"))); // NOI18N
        jButton1.setText("Sair desta Janela");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/cancel.png"))); // NOI18N
        jButton2.setText("Sair da Aplicação");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        try {
            jCadastroCompromissoData.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jCadastroCompromissoData.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCadastroCompromissoDataActionPerformed(evt);
            }
        });

        jLabel1.setText("Data");

        jButtonDisponibilidade.setText("Disponibilidade de data");
        jButtonDisponibilidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDisponibilidadeActionPerformed(evt);
            }
        });

        jTabelaCandidatos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jTabelaCandidatos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTabelaCandidatosMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(jTabelaCandidatos);

        jLabel2.setText("Disponíveis");

        jLabel3.setText("Escolhidos");

        jTextAreaUsuarioEscolhidos.setColumns(20);
        jTextAreaUsuarioEscolhidos.setRows(5);
        jScrollPane4.setViewportView(jTextAreaUsuarioEscolhidos);

        javax.swing.GroupLayout painelPrincipalLayout = new javax.swing.GroupLayout(painelPrincipal);
        painelPrincipal.setLayout(painelPrincipalLayout);
        painelPrincipalLayout.setHorizontalGroup(
            painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelPrincipalLayout.createSequentialGroup()
                .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(painelPrincipalLayout.createSequentialGroup()
                        .addGap(35, 35, 35)
                        .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(painelPrincipalLayout.createSequentialGroup()
                                .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(painelPrincipalLayout.createSequentialGroup()
                                        .addGap(105, 105, 105)
                                        .addComponent(jCadastroCompromissoHoraInicio, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(HInicio))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(HTermino)
                                .addGap(18, 18, 18)
                                .addComponent(jCadastroHoraFim, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(painelPrincipalLayout.createSequentialGroup()
                                .addComponent(lbNome)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jCadastroCompromissoNome, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(painelPrincipalLayout.createSequentialGroup()
                                .addGap(67, 67, 67)
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jCadastroCompromissoData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButtonDisponibilidade))
                            .addGroup(painelPrincipalLayout.createSequentialGroup()
                                .addComponent(descricao)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelPrincipalLayout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelPrincipalLayout.createSequentialGroup()
                                .addComponent(btnSalvar)
                                .addGap(52, 52, 52))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelPrincipalLayout.createSequentialGroup()
                                .addComponent(jButton1)
                                .addGap(11, 11, 11)))))
                .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(painelPrincipalLayout.createSequentialGroup()
                        .addGap(62, 62, 62)
                        .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel2)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
                            .addComponent(jLabel3)
                            .addComponent(jScrollPane4))
                        .addGap(76, 76, 76))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelPrincipalLayout.createSequentialGroup()
                        .addComponent(btnCancelar)
                        .addGap(209, 209, 209))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelPrincipalLayout.createSequentialGroup()
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(174, 174, 174))))
        );
        painelPrincipalLayout.setVerticalGroup(
            painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelPrincipalLayout.createSequentialGroup()
                .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(painelPrincipalLayout.createSequentialGroup()
                        .addGap(48, 48, 48)
                        .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbNome)
                            .addComponent(jCadastroCompromissoNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(HInicio)
                            .addComponent(jCadastroCompromissoHoraInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jCadastroHoraFim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(HTermino)))
                    .addGroup(painelPrincipalLayout.createSequentialGroup()
                        .addGap(7, 7, 7)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(30, 30, 30)
                .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jCadastroCompromissoData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonDisponibilidade)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(descricao)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(22, 22, 22)
                .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSalvar)
                    .addComponent(btnCancelar))
                .addGap(18, 18, 18)
                .addGroup(painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addGap(107, 107, 107))
        );

        menuArquivo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/house.png"))); // NOI18N
        menuArquivo.setText("Arquivo");
        menuArquivo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuArquivoActionPerformed(evt);
            }
        });
        menuArquivo.addMenuDragMouseListener(new javax.swing.event.MenuDragMouseListener() {
            public void menuDragMouseDragged(javax.swing.event.MenuDragMouseEvent evt) {
                menuArquivoMenuDragMouseDragged(evt);
            }
            public void menuDragMouseEntered(javax.swing.event.MenuDragMouseEvent evt) {
            }
            public void menuDragMouseExited(javax.swing.event.MenuDragMouseEvent evt) {
            }
            public void menuDragMouseReleased(javax.swing.event.MenuDragMouseEvent evt) {
            }
        });

        subMenuSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/door_out.png"))); // NOI18N
        subMenuSair.setText("Sair");
        subMenuSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuSairActionPerformed(evt);
            }
        });
        menuArquivo.add(subMenuSair);

        BarradeMenus.add(menuArquivo);

        menuSobre.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/information.png"))); // NOI18N
        menuSobre.setText("Sobre");
        menuSobre.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                menuSobreMouseClicked(evt);
            }
        });
        menuSobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuSobreActionPerformed(evt);
            }
        });
        BarradeMenus.add(menuSobre);

        setJMenuBar(BarradeMenus);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(painelPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(painelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 408, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
        ModeloReuniao reuniao = new ModeloReuniao();
        reuniao.setNome(jCadastroCompromissoNome.getText());
        reuniao.setData(jCadastroCompromissoData.getText());
        reuniao.setHoraInicio(jCadastroCompromissoHoraInicio.getText());
        reuniao.setHoraFim(jCadastroHoraFim.getText());
        reuniao.setDescricao(jCadastroCompromissoDescricao.getText());
        String[] escolhidos = jTextAreaUsuarioEscolhidos.getText().split(";");
        //loop para pegar as ids dos escolhidos
        
        ControleReunioes controleR = new ControleReunioes();
        ControleUsuarios controleU = new ControleUsuarios();
        int i = 0;
        //loop registrar reuniao
        
        for (String elem : escolhidos) {
            int id = controleU.descobreID(elem);
            controleR.inserirReuniao(reuniao, id,gerente.getId());            
        }
        JOptionPane.showMessageDialog(rootPane,"Salvo com Sucesso digníssimo "+gerente.getNome());
    }//GEN-LAST:event_btnSalvarActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        jCadastroCompromissoNome.setText("");
        jCadastroCompromissoData.setText("");
        jCadastroCompromissoDescricao.setText("");
        jCadastroCompromissoHoraInicio.setText("");
        jCadastroHoraFim.setText("");
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void jCadastroCompromissoNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCadastroCompromissoNomeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCadastroCompromissoNomeActionPerformed

    private void btnSalvarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSalvarMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_btnSalvarMouseClicked

    private void btnCancelarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelarMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_btnCancelarMouseClicked

    private void subMenuSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuSairActionPerformed
        fechar();
    }//GEN-LAST:event_subMenuSairActionPerformed

    private void menuArquivoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuArquivoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_menuArquivoActionPerformed

    private void menuArquivoMenuDragMouseDragged(javax.swing.event.MenuDragMouseEvent evt) {//GEN-FIRST:event_menuArquivoMenuDragMouseDragged
        // TODO add your handling code here:
    }//GEN-LAST:event_menuArquivoMenuDragMouseDragged

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        fechar();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
      if(javax.swing.JOptionPane.showConfirmDialog(null,"Deseja Fechar?","ATENÇÂO ",javax.swing.JOptionPane.YES_NO_OPTION )==0){  
                System.exit(0);
            }  
    }//GEN-LAST:event_jButton2ActionPerformed

    private void menuSobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSobreActionPerformed

    }//GEN-LAST:event_menuSobreActionPerformed

    private void menuSobreMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_menuSobreMouseClicked
        new Sobre().setVisible(true);
    }//GEN-LAST:event_menuSobreMouseClicked

    private void jTabelaCandidatosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabelaCandidatosMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jTabelaCandidatosMouseClicked

    private void jCadastroHoraFimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCadastroHoraFimActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCadastroHoraFimActionPerformed

    private void jCadastroCompromissoHoraInicioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCadastroCompromissoHoraInicioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCadastroCompromissoHoraInicioActionPerformed

    private void jCadastroCompromissoDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCadastroCompromissoDataActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCadastroCompromissoDataActionPerformed

    private void jButtonDisponibilidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDisponibilidadeActionPerformed
        try {
            preencherTabelaDisponibilidade();
        } catch (ParseException ex) {
            JOptionPane.showMessageDialog(rootPane, "Erro em preenche a tabela de candidatos\nErro: "+ex);
        }
    }//GEN-LAST:event_jButtonDisponibilidadeActionPerformed
    private void formFrameClosing(javax.swing.event.InternalFrameEvent evt) {                                            
        this.fechar();  
    }   
  
    private void fechar(){  
            if(javax.swing.JOptionPane.showConfirmDialog(null,"Deseja Fechar?","ATENÇÂO ",javax.swing.JOptionPane.YES_NO_OPTION )==0){  
                this.dispose();  
            }  
        }
    
    public void preencherTabela(){
    
//        conecta.executaSQL(sql);
//        try {
//            conecta.rs.first();
//            do {
//                dados.add(new Object[]{conecta.rs.getInt("ID"),conecta.rs.getString("nome"), conecta.rs.getString("status")});
//            } while (conecta.rs.next());
//        } catch (SQLException ex) {
//            JOptionPane.showMessageDialog(rootPane, "Erro ao preencher a tabela:\nERRO"+ex);
//        }
        ArrayList cadidatos = new ArrayList<>();
        
        ControleUsuarios controle = new ControleUsuarios();
        cadidatos = controle.listaCandidatos(cadidatos);
        
        String[] Colunas = new String[]{"Nome"};        
        UtilitariosTables tabela = new UtilitariosTables(cadidatos, Colunas);
        jTabelaCandidatos.setModel(tabela);
        jTabelaCandidatos.getColumnModel().getColumn(0).setPreferredWidth(400);
        jTabelaCandidatos.getColumnModel().getColumn(0).setResizable(false);        
        jTabelaCandidatos.getTableHeader().setReorderingAllowed(false);
        jTabelaCandidatos.setAutoResizeMode(jTabelaCandidatos.AUTO_RESIZE_OFF);
        jTabelaCandidatos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
    
    public void preencherTabelaDisponibilidade() throws ParseException{
        ArrayList<Integer> candidatos = new ArrayList<>();
        ArrayList disponiveis = new ArrayList();
        
        ControleUsuarios controleU = new ControleUsuarios();
        ControleReunioes controleR = new ControleReunioes();
        //temp
        String stringData = jCadastroCompromissoData.getText();
        SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yyyy");
        java.sql.Date datainicio = new java.sql.Date(formatter.parse(stringData).getTime());

        Calendar calendario = new GregorianCalendar();
        calendario.setTime(datainicio);
        String [] horainicio = jCadastroCompromissoHoraInicio.getText().split(":");
        calendario.set(Calendar.HOUR_OF_DAY,Integer.parseInt(horainicio[0]));         
        calendario.set(Calendar.MINUTE,Integer.parseInt(horainicio[1]));
        datainicio.setTime(calendario.getTimeInMillis());


        String[] horafim = jCadastroHoraFim.getText().split(":");
        calendario.set(Calendar.HOUR_OF_DAY,Integer.parseInt(horafim[0]));         
        calendario.set(Calendar.MINUTE,Integer.parseInt(horafim[1]));     
        java.sql.Date datafim = new java.sql.Date(calendario.getTimeInMillis());
 
          //temp
        candidatos = controleR.verificaDisponibilidade(datainicio, datafim);
        disponiveis = controleU.descobreNomes(candidatos);
        
        String[] Colunas = new String[]{"Nome"};        
        UtilitariosTables tabela = new UtilitariosTables(disponiveis, Colunas);
        jTabelaCandidatos.setModel(tabela);
        jTabelaCandidatos.getColumnModel().getColumn(0).setPreferredWidth(400);
        jTabelaCandidatos.getColumnModel().getColumn(0).setResizable(false);        
        jTabelaCandidatos.getTableHeader().setReorderingAllowed(false);
        jTabelaCandidatos.setAutoResizeMode(jTabelaCandidatos.AUTO_RESIZE_OFF);
        jTabelaCandidatos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }    
    
    static conectaBanco conecta = new conectaBanco();
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CadastroReuniao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CadastroReuniao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CadastroReuniao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CadastroReuniao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        conecta.conexao();
        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CadastroReuniao().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuBar BarradeMenus;
    private javax.swing.JLabel HInicio;
    private javax.swing.JLabel HTermino;
    private javax.swing.JToggleButton btnCancelar;
    private javax.swing.JToggleButton btnSalvar;
    private javax.swing.JLabel descricao;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButtonDisponibilidade;
    private javax.swing.JFormattedTextField jCadastroCompromissoData;
    private javax.swing.JTextArea jCadastroCompromissoDescricao;
    private javax.swing.JFormattedTextField jCadastroCompromissoHoraInicio;
    private javax.swing.JTextField jCadastroCompromissoNome;
    private javax.swing.JFormattedTextField jCadastroHoraFim;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollBar jScrollBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTable jTabelaCandidatos;
    private javax.swing.JTextArea jTextAreaUsuarioEscolhidos;
    private javax.swing.JLabel lbNome;
    private javax.swing.JMenu menuArquivo;
    private javax.swing.JMenu menuSobre;
    private javax.swing.JPanel painelPrincipal;
    private javax.swing.JMenuItem subMenuSair;
    // End of variables declaration//GEN-END:variables
}
